$(function(){
    $('.tablist li').on('click',function (e) {
        $(this).addClass('active').siblings().removeClass('active')
        var index = $(this).index();
        $('.tablist-item').eq(index).addClass('active').siblings().removeClass('active')
        var len = $('.tablist li').length;
        if(len -1 === index){
            $('.twelve').addClass('active')
        }else{
            $('.tewlve').removeClass('active')
        }
    })
    //var date=new Date('2017-9-15').getTime();
    // 日期格式化方法
    Date.prototype.format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1,                 //月份 
            "d+": this.getDate(),                    //日 
            "h+": this.getHours(),                   //小时 
            "m+": this.getMinutes(),                 //分 
            "s+": this.getSeconds(),                 //秒 
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
            "S": this.getMilliseconds()             //毫秒 
        };
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        }
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            }
        }
        return fmt;
    }        
    var date = new Date().format("yyyy-MM-dd");
    var pickerObj = {
        aRecent90Days: 'aRecent90Days', //最近90天
        // isTodayValid : true,
        isTodayValid: true,
        startDate: '',
        endDate: '',
        magicSelect: false,
        needCompare: false,
        defaultText: '止',
        autoSubmit: true,
        //stopToday : false,
        //autoSubmit : true, 
        inputTrigger: 'input_trigger1',
        success: function (obj) {
            console.log(obj)
        },
        theme: 'ta'
    }
    var dateRange1 = new pickerDateRange('date1', pickerObj);
    var dateRange2 = new pickerDateRange('date2', pickerObj);
    var dateRange3 = new pickerDateRange('date3', pickerObj);
    var dateRange4 = new pickerDateRange('date4', pickerObj);
    var dateRange5 = new pickerDateRange('date5', {
        aRecent90Days: 'aRecent90Days', //最近90天
        // isTodayValid : true,
        isTodayValid: true,
        startDate: '',
        endDate: '',
        magicSelect: false,
        needCompare: false,
        defaultText: '止',
        autoSubmit: true,
        shortOpr: true, //结合单天日期选择的短操作，不需要确定和取消的操作按钮。
        singleDate: true, // 单日选择
        showBefAft: true, //底部显示按钮
        //stopToday : false,
        //autoSubmit : true, 
        inputTrigger: 'input_trigger1',
        success: function (obj) {
            console.log(obj)
        },
        theme: 'ta'
    });
    

})



$(function() {
    //图形长度计算
    $('.result-sequence .line').each(function (index,val) {
        var n =Number($(val).text().slice(0,-1));

        $(this).css({
            width: n/100*560+'px'
        })

    })

    //模拟select选择
    $('.select').on('click',function(e) {
        $('body').trigger('click')
        e.stopPropagation();
        e.preventDefault();
        $(this).toggleClass('active');
        $(this).parent().children('.select-items').toggleClass('active')
    })
    $('.select-items ul').on('click','li',function(e) {
        var txt = $(this).text()
        $(this).parent().parent().parent().children('.select').text(txt).removeClass('active');
        $(this).addClass('active').siblings().removeClass('active')
        $(this).parent().parent().removeClass('active')
    })
    $('body').on('click',function() {
        $('.select-items').removeClass('active')
        $('.select').removeClass('active')
    })

    //12点前后内切换

    $('.twelve ul').on('click','li',function(e) {
        $(this).addClass('active').siblings().removeClass('active')
    })

     $(window).load(function(){
                $('.select-items ul').mCustomScrollbar({
                    theme: "minimal-dark"
                });
        });
})